import 'package:equatable/equatable.dart';
import 'package:website.core/core/domain/entities/money_amount.dart';

const kApiMoneyAmountValueKey = 'value';
const kApiMoneyAmountCurrencyKey = 'currency';

class ApiMoneyAmountDto extends Equatable {
  const ApiMoneyAmountDto._internal({
    required this.value,
    required this.currency,
  });

  final String value;
  final String currency;

  @override
  List<Object?> get props {
    return [
      value,
      currency,
    ];
  }

  factory ApiMoneyAmountDto.fromJson(Map<String, dynamic> json) {
    return ApiMoneyAmountDto._internal(
      value: json[kApiMoneyAmountValueKey],
      currency: json[kApiMoneyAmountCurrencyKey],
    );
  }

  MoneyAmount toEntity() {
    return MoneyAmount(
      value: value,
      currency: currency,
    );
  }
}
